﻿using MangoMes.Commont.Domain;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;
using System.Runtime.ConstrainedExecution;
using System;
using MangoMes.Commont.DapperHelps;

namespace MangoMes.Write.API.Applications.Enterprises
{
    public class EnterpriseListHandler : IRequestHandler<EnterpriseListCommond,List<Enterprise>>
    {
        private readonly IBateRepository<Enterprise> enter;
        public EnterpriseListHandler(IBateRepository<Enterprise> enter)
        {
            this.enter = enter;
        }
        public async Task<List<Enterprise>> Handle(EnterpriseListCommond request, CancellationToken cancellationToken)
        {
            DapperHelper helper = new DapperHelper();
            Enterprise enterprise=new Enterprise();
            string conn = helper.MangoMesWrite;
            string str = "select * from enterprisetable";
            var res = enter.GetAll(str, enterprise, conn).ToList();
            return res;

            

        }
    }
}

